//
//  Team.m
//
//  Created by Kevin Schewior on 04.12.11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Team.h"


@implementation Team

@synthesize name, current_money, current_points, players, base_long, base_lat;

-(id)initWithName:(NSString *)pName{
	self = [super init];
	if(self){
		name= [[NSString alloc] initWithString:pName];
		current_money=0;
		current_points=0;
        base_long=0.0;
        base_lat=0.0;
		players=[[NSMutableDictionary alloc] initWithCapacity:3];
	}
	return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super init];
    if (self) {
        name = [[NSString alloc] initWithString:[aDecoder decodeObjectForKey:@"name"]];
        current_money = [aDecoder decodeIntForKey:@"current_money"];
        current_points = [aDecoder decodeIntForKey:@"current_points"];
        base_long = [aDecoder decodeDoubleForKey:@"base_long"];
        base_lat = [aDecoder decodeDoubleForKey:@"base_lat"];        
        players = [[aDecoder decodeObjectForKey:@"players"] retain];		
    }
    
    return self;
}

-(void)encodeWithCoder:(NSCoder *)aCoder{
  [aCoder encodeObject:name forKey:@"name"];
  [aCoder encodeInt:current_money forKey:@"current_money"];
  [aCoder encodeInt:current_points forKey:@"current_points"];
  [aCoder encodeDouble:base_long forKey:@"base_long"];
  [aCoder encodeDouble:base_lat forKey:@"base_lat"];    
  [aCoder encodeObject:players forKey:@"players"];
}

-(void)dealloc{
    [name release];
	[players release];
	[super dealloc];
}

-(NSString*) description {
  return [NSString stringWithFormat:@"ID: %@ PLAYERS: %@", name, players];
}

#pragma Located methods

-(double) latitude {
    return base_lat;
}

-(double) longitude {
    return base_long;
}

-(double) accuracy {
    return 1;
}

-(NSDate*) lastUpdate {
    return nil;
}

@end
